<%@ taglib prefix="s" uri="/struts-tags" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2015/7/23
  Time: 23:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#get").click(function () {
                $("#msgName").html("");
//                $("#get").attr("disabled", true);
                var url = "register";
                $.ajax({
                    url: url,
                    type: "post",
                    data: null,
                    dataType: "json",
                    success: function (data) {
                        $("#msgName").append("<p>编号&nbsp;&nbsp;&nbsp;&nbsp;姓名&nbsp;&nbsp;&nbsp;&nbsp;密码</p>");
                        for (var i = 0; i < data.users.length; i++) {
                            $("#msgName").append("<p>" + data.users[i].userId + "&nbsp;&nbsp;&nbsp;&nbsp" + data.users[i].userName + "&nbsp;&nbsp;&nbsp;&nbsp" + data.users[i].userPassword + "</p>");
                        }
                        $("#get").attr("disabled", false);
//                        $("#msgName").replaceWith(data.user.userName);
//                        $("#msgName").replace(data.user.userName)
                    },
                    error: function () {
                        alert("ajax请求失败")
                    }

                })
            })
        })
    </script>
</head>
<body>
<s:form action="login" method="POST">
    用户名<s:textfield name="user.userName"></s:textfield>
    密&nbsp;&nbsp;&nbsp;码<s:password name="user.userPassword"></s:password>
</s:form>

<input type="button" value="ajax取得用户信息" id="get">

<div id="msgName"></div>
</body>
</html>
